# -*- encoding: utf-8 -*-
"""
========================================
@Time   ：2021/9/8 17:22
@Auther ：shutao
@File   ：base_metric.py
@IDE    ：PyCharm
@Github ：https://github.com/NameLacker
@Gitee  ：https://gitee.com/nameLacker
========================================
"""
from abc import abstractmethod
import paddle


class BaseMetric(paddle.metric.Metric):
    """Base class for any metric"""

    def __init__(self):
        super(BaseMetric, self).__init__()
        # 准确率指标
        self.acc = 0.
        # 回归率指标
        self.recall = 0.
        # 平均 IOU
        self.mIOU = 0.
        # 多类别平均 AP
        self.mAP = 0.

    @abstractmethod
    def reset(self):
        """
        重置
        Returns:

        """
        pass

    @abstractmethod
    def update(self, preds, label, **kwargs):
        """
        计算指标
        Args:
            preds:
            label:
            **kwargs:

        Returns:

        """
        pass

    @abstractmethod
    def accumulate(self) -> float:
        """
        计算最终精度
        Returns:

        """
        pass

    @abstractmethod
    def name(self) -> str:
        """
        验证方法名称
        Returns:

        """
        pass
